package org.ciallo.simplemusicplayer.data.model;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;

/**
 * @author Jukomu
 * @Description: 代表歌曲播放次数的实体
 * @Package: org.ciallo.simplemusicplayer.data.model
 * @Project: SimpleMusicPlayer
 * @name: PlayCount
 * @Date: 2025/6/13-07:47
 * @Filename: PlayCount
 */
@Entity(tableName = "play_counts",
        foreignKeys = @ForeignKey(entity = Song.class,
                parentColumns = "id",
                childColumns = "song_id",
                onDelete = ForeignKey.CASCADE)) // 如果Song被删除，其播放计数也删除
public class PlayCount {

    @PrimaryKey
    @ColumnInfo(name = "song_id")
    public long songId;

    @ColumnInfo(name = "play_count", defaultValue = "1") // 初始值为1
    public int playCount;

    public PlayCount(long songId, int playCount) {
        this.songId = songId;
        this.playCount = playCount;
    }
}
